﻿using System.Collections.Generic;
using System.Diagnostics;
using System.Xml.Serialization;
using Kotonoha.Objects.SuperMemo;

namespace Kotonoha.Server.Objects.Model {
    [XmlRoot]
    public class Container {
        private List<Word> words = new List<Word>();
        private List<Kanji> kanji = new List<Kanji>();
        private List<OFMatrixItem> matrix = new List<OFMatrixItem>();
        private Dictionary<long, Word> wordMap = new Dictionary<long, Word>();

        public List<Word> Words {
            [DebuggerStepThrough]
            get { return words; }
            [DebuggerStepThrough]
            set {
                words = value;
            }
        }

        public List<Kanji> Kanji {
            [DebuggerStepThrough]
            get { return kanji; }
            [DebuggerStepThrough]
            set { kanji = value; }
        }

        public List<OFMatrixItem> Matrix {
            get { return matrix; }
            set { matrix = value; }
        }

        public void buildWordMap() {
            wordMap.Clear();
            words.ForEach(w => wordMap.Add(w.Id, w));
        }

        public Word getWord(long id) {
            return wordMap[id];
        }
    }
}